<?php
if(!defined('DCS_ROOT')) {exit('Access Denied');}

class check {

	function defaultAction(){	
		$DB  = getDB();
		header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
		header( 'Cache-Control: no-store, no-cache, must-revalidate' );
		header( 'Cache-Control: post-check=0, pre-check=0', false );
		header( 'Pragma: no-cache' );
		header( 'content-Type: text/html; charset=utf-8');
		$action =  $_POST['action'];
		if($action == 'username'){
			$username = trim(htmlentities($_POST['username']));
			if($username !=''){
				$check = 'member';
				$sql ="SELECT username from $check where username = '$username' ";
				$DB->query($sql);
				$rs = $DB->recordCount();
				if ($rs!=0){	
					$text='no';
				}else{
					$text='yes';
				}
			}else{
				$text='error';
			}
			echo $text;
		}elseif($action == 'email'){
			$email = trim(htmlentities($_POST['email']));
			if($email !=''){
				$check = 'member';
				$sql ="SELECT email from $check where email = '$email' ";
				$DB->query($sql);
				$rs = $DB->recordCount();
				if ($rs!=0){	
					$text='no';
				}else{
					$text='yes';
				}
			}else{
				$text='error';
			}
			echo $text;
		}else{
			echo 'error';
		}

	}


}

?>
